//
//  JYJBestMusicListCollectionViewCell.m
//  HappyListen
//
//  Created by 冀永金 on 16/8/30.
//  Copyright © 2016年 冀永金. All rights reserved.
//

#import "JYJBestMusicListCollectionViewCell.h"
#import "BaseLabel.h"
#import "Masonry.h"
#import "UIImageView+WebCache.h"
#import "JYJMusicsContentModel.h"
#import "JYJTAMacro.h"
@interface JYJBestMusicListCollectionViewCell ()
@property (nonatomic, strong) UIImageView *backImage;
@property (nonatomic, strong) BaseLabel *titleLabel;
@property (nonatomic, strong) UIImageView *img;
@end
@implementation JYJBestMusicListCollectionViewCell
- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self configViews];
    }
    return self;
}
- (void)configViews {
    self.img =[[UIImageView alloc]init];
    [self.contentView addSubview:_img];
    self.backImage = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"find_cat_cover-1"]];
    [self.contentView addSubview:_backImage];
    self.titleLabel = [[BaseLabel alloc]init];
    self.titleLabel.font = [UIFont systemFontOfSize:16];
    self.titleLabel.numberOfLines = 2;
    self.titleLabel.textColor = [UIColor whiteColor];
    [self.contentView addSubview:_titleLabel];
    
    
}
- (void)layoutSubviews {
    [super layoutSubviews];
    [self.backImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView.mas_top).with.offset(0);
        make.left.equalTo(self.contentView.mas_left).with.offset(0);
        make.width.mas_equalTo(self.contentView.bounds.size.width);
        make.height.mas_equalTo(self.contentView.bounds.size.width);
    }];
    [self.img mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView.mas_top).with.offset(11);
        make.left.equalTo(self.contentView.mas_top).with.offset(11);
        make.width.mas_equalTo(self.contentView.frame.size.width - 22);
        make.height.mas_equalTo(self.contentView.frame.size.width - 22);
        
    }];
    self.img.layer.cornerRadius = (self.contentView.frame.size.width - 22) / 2;
    self.img.clipsToBounds = YES;
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.backImage.mas_bottom).with.offset(5);
        make.left.equalTo(self.contentView.mas_left).with.offset(0);
        make.width.mas_equalTo(self.contentView.bounds.size.width);
        make.height.mas_equalTo(40);
    }];
}
- (void)setMusicContentModel:(JYJMusicsContentModel *)musicContentModel {
    _musicContentModel = musicContentModel;
    [self.img sd_setImageWithURL:[NSURL URLWithString:musicContentModel.music_img] placeholderImage:PLACEHOLDERIMAGE];
    self.titleLabel.text = musicContentModel.music_title;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
